# @Version        : 1.0
# @Update Time    : 2025/8/16 20:37
# @File           : __init__.py.py
# @IDE            : PyCharm
# @Desc           : 文件描述信息
from fastapi import FastAPI
from fastapi import Request
from fastapi_stoplight import get_stoplight_elements_html
from scalar_fastapi import get_scalar_api_reference

from applications.view.system import register_system_route


def init_routes(app: FastAPI):
    register_system_route(app)

    # stoplight 添加文档路由
    @app.get("/docs/stoplight", include_in_schema=False)
    def stoplight_html(request: Request):
        return get_stoplight_elements_html(openapi_url=app.openapi_url, title=app.title)

    @app.get("/docs/scalar", include_in_schema=False)
    async def scalar_html():
        return get_scalar_api_reference(
            title=app.title,
            openapi_url=app.openapi_url,
        )